package com.lvyq.javaprint.model;

import com.lvyq.javaprint.util.SettingUtils;
import javafx.beans.property.SimpleStringProperty;

/**
 * @author lvyq 代理设置
 * @version 1.0
 * Create by 2025-01-06 16:47
 */
public class ProxySettingModel {

    /**
     *  1 不使用代理 2网页代理（HTTP）
     */
    private  SimpleStringProperty type = new SimpleStringProperty() ;

    /**
     *  ip 地址/域名
     */
    private  SimpleStringProperty domain = new SimpleStringProperty();

    /**
     *  端口号
     */
    private  SimpleStringProperty port = new SimpleStringProperty();


    /**
     *  服务本身
     */
    private SimpleStringProperty serverPort = new SimpleStringProperty();

    public String getServerPort() {
        return serverPort.get();
    }

    public SimpleStringProperty serverPortProperty() {
        return serverPort;
    }

    public void setServerPort(String serverPort) {
        this.serverPort.set(serverPort);
    }

    public String getType() {
        return type.get();
    }

    public SimpleStringProperty typeProperty() {
        return type;
    }

    public void setType(String type) {
        this.type.set(type);
    }

    public String getDomain() {
        return domain.get();
    }

    public SimpleStringProperty domainProperty() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain.set(domain);
    }

    public String getPort() {
        return port.get();
    }

    public SimpleStringProperty portProperty() {
        return port;
    }

    public void setPort(String port) {
        this.port.set(port);
    }

    public void loadData() {
        //读取setting.xml 数据
        ProxySettingModel proxySettingModel = SettingUtils.readProxySetting();
        //服务端口号
        String serverPort = SettingUtils.readServerPort();
        setType(proxySettingModel.getType());
        setDomain(proxySettingModel.getDomain());
        setPort(proxySettingModel.getPort());
        setServerPort(serverPort);
    }
}
